***Figure 1(c)
	 
	 *global path = "C:\Users\creto\Desktop\chinese_students_2017"
	 
	 
	 //ISIC codes and labels
	 insheet using "USNTRrate9713_TRAINS.csv", comma clear
	 contract product productname
	 tempfile isiclabels
	 
	 rename product isic
	 rename productname isic_label
	 save "`isiclabels'", replace
	 
	 
	 
	 //LOAD  TARIFF DATA
	 
	 use "isic_gap_manuf.dta", clear

		 rename s1999 ntrgap
		 gen nonntr_rate = ntrgap + ntr_rate
		
		destring isic_str, gen(isic)
		merge m:1 isic using "`isiclabels'"
	    keep if _merge==3
	 
	 
	 
	 sort isic
	 gen n=_n
	 egen isic3 = axis(n), label(isic_str)
	 
	 drop if isic3==.

	 
	 *labels for particular industries
	  foreach x in 5 25 50 75 95 {
		sum ntrgap, de
		sum isic if ntrgap==r(p`x')
		local p`x'=`r(mean)'
	  }
	  
	  gen want = (isic==`p5'|isic==`p25'|isic==`p50'|isic==`p75'|isic==`p95')
	 
	 gen indlabels = want*isic_label
	 
	replace indlabels = "Soft Drinks" if indlabels=="Manufacture of soft drinks; production of mineral"
	replace indlabels = "Leather Tanning" if indlabels=="Tanning and dressing of leather"
	replace indlabels = "Paper/Paperbooks" if indlabels=="Manufacture of other articles of paper and paperbo"
	replace indlabels = "Recorded Media" if indlabels=="Publishing of recorded media"
	replace indlabels = "Insulated Wire" if indlabels=="Manufacture of insulated wire and cable"

**coordinates for arrow
input y1_a1 x1_a1 y2_a1 x2_a1
.7 13 .606368 18
end

input y1_a2 x1_a2 y2_a2 x2_a2	
.7 45 .5934591 40
end 


 gr tw (bar nonntr_rate isic3, color(red*1.5)) (bar ntr_rate isic3, color(blue*.75)) ///
	   (pcarrow y1_a1 x1_a1 y2_a1 x2_a1, mc(black) lc(black)) ///
	   (pcarrow y1_a2 x1_a2 y2_a2 x2_a2, mc(black) lc(black)) ///
	   (scatter ntrgap isic3, ms(none) ///
	   text(.7 13 "Tobacco", size(small) color(black) placement(nwest)) ///
	   text(.7 45 "Recorded Media", size(small) color(black) placement(neast)) ) , ///
	   scheme(s1color) xtitle("Industry (ISIC)", size(small)) xlabel(none) ///
	   ytitle(Tariff Rate (percent), angle(90) size(small)) ///
	   ylabel(#8, labsize(small)) legend(order(1 2) label(1 "Non-NTR Rate") label(2 "NTR Rate") size(small))
		
*graph export "$path/Figures/fig_ntr_vs_nonntr.eps", replace fontface("Palatino Linotype")

		
		
 gr tw (bar nonntr_rate isic3, color(gs10)) (bar ntr_rate isic3, color(gs0)) ///
	   (pcarrow y1_a1 x1_a1 y2_a1 x2_a1, mc(black) lc(black)) ///
	   (pcarrow y1_a2 x1_a2 y2_a2 x2_a2, mc(black) lc(black)) ///
	   (scatter ntrgap isic3, ms(none) ///
	   text(.7 13 "Tobacco", size(small) color(black) placement(nwest)) ///
	   text(.7 45 "Recorded Media", size(small) color(black) placement(neast)) ) , ///
	   scheme(s1color) xtitle("Industry (ISIC)", size(small)) xlabel(none) ///
	   ytitle(Tariff Rate (percent), angle(90) size(small)) ///
	   ylabel(#8, labsize(small)) legend(order(1 2) label(1 "Non-NTR Rate") label(2 "NTR Rate") size(small))
		
*graph export "$path/Figures/fig_ntr_vs_nonntr_bw.eps", replace fontface("Palatino Linotype")		
drop y1* x1* y2* x2*

**coordinates for arrow
input y1_a1 x1_a1 y2_a1 x2_a1
.35 13 .316917 18
end

input y1_a2 x1_a2 y2_a2 x2_a2	
.6 45 .571219 40
end 
		
		
 gr tw (bar ntrgap isic3, color(green*1.5)) ///
	   (pcarrow y1_a1 x1_a1 y2_a1 x2_a1, mc(black) lc(black)) ///
	   (pcarrow y1_a2 x1_a2 y2_a2 x2_a2, mc(black) lc(black)) ///
	   (scatter ntrgap isic3, ms(none) ///
	   text(.35 13 "Tobacco", size(small) color(black) placement(nwest)) ///
	   text(.6 45 "Recorded Media", size(small) color(black) placement(neast)) ) , ///
	   scheme(s1color) xtitle("Industry (ISIC)", size(small)) xlabel(none) ///
	   ytitle(Tariff Rate (percent), angle(90) size(small)) ///
	   ylabel(#8, labsize(small)) legend(order(1) label(1 "NTR Gap = Non-NTR Rate - NTR Rate") size(small))
		
		
		

*graph export "$path/Figures/fig_ntrgaps.eps", replace fontface("Palatino Linotype")
*graph export "$path/Presentations/Barcelona Migration 2019/fig_ntr_vs_nonntr.eps", replace fontface("Palatino Linotype")		

